<template>
  <el-dialog
      v-model="visible"
      title="新增数据表"
      width="600px"
  >
  <el-input v-model="TableID" placeholder="请输入你要删除的表ID"></el-input>
    <template #footer>
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="handleSubmit">提交</el-button>
    </template>
  </el-dialog>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import { useTableService } from '@/api/Table/TableApi' // 导入表格服务

// 在组件中使用表格服务
const { deleteTable, loading: createLoading } = useTableService()

const visible = ref(false)
const TableID =ref()

const emit = defineEmits(['success'])

const handleSubmit = async () => {
  const response = await deleteTable({
  tableId:TableID.value,
  })
  // 关闭对话框
  visible.value = false
  // 重置表单
   TableID.value =0
  ElMessage.success("删除成功")
}
// 暴露打开方法
const open = (tableId?: number) => {
  TableID.value = tableId
  visible.value = true
}

defineExpose({ open })
</script>
